	var __$ = function(id) { return document.getElementById(id); }

	//定义容器初始位置
	var _start_x = 104;
	var _start_y = 156;
	//容器间距
	var _div_margin_left = 3;
	var _div_padding_top = 3;
	//容器大小
	var _div_w = 77;
	var _div_h = 94;

	//定义滑块大小
	var _drop_w = 77;
	var _drop_h = 90;

	var scroll_height = _div_h + 2;	//最大滚动距离
	var strContent = Array('0','1','2','3','4','5','6','7','8','9');	//滑块上的内容
	var speed = Array(0, 0, 0);	//三个不同速度

	var pointer0 = Array(0,0,0);	//进度指针 0
	var pointer1 = Array(1,1,1);	//进度指针 1

	var all_y0 = Array(0,0,0);	//当前高度 0
	var all_y1 = Array(0,0,0);	//当前高度 1

	var now_status = 'stop';	//当前运动状态
	var stop_speed = 3;	//停止前的速度
	var domove = 0;	//定时器对象

	var award_info = Array(-1, -1, -1);	//停盘值数组
	var award_pointer = 0;

	var award_num = '';	//初始化停盘值

	function startMove()
	{
		//只在停止状态时有效
		if (domove == 0)
		{
			init_move();	//初始化数据
			domove = setInterval(move_it, 2);
			now_status = 'run';
			setTimeout(stopMove, 1000);
			__$('start_move').disabled = true;
		}
	}

	function init_move()
	{
		award_num = __$('award_str').value;
		__$('stop_info').value = '';
		if (award_num == '' || award_num.length < 3)
		{
			award_num = '123';
		}
		award_info[0] = -1; award_info[1] = -1; award_info[2] = -1;
		award_pointer = 0;
		for(var _i=0; _i<3; _i++)
		{
			//随机设置三种速度
			speed[_i] = Math.round(Math.random() * 10) + 40;
		}
	}

	function move_it()
	{
		for(var _i=0; _i<3; _i++)
		{
			var __di0 = __$('dropimg_'+_i+'0');
			var __di1 = __$('dropimg_'+_i+'1');

			if (speed[_i] == 0)
			{
				continue;
			}

			//在1号滑块消失时填入下一个要显示的内容
			if(all_y0[_i] < 0 && (all_y0[_i] + speed[_i])>=0)
			{
				pointer1[_i] = pointer0[_i] < (strContent.length-1) ? (pointer0[_i] + 1) : (pointer0[_i] + 1) - strContent.length;
			}

			//设置滑块位置数据
			all_y0[_i] = ((all_y0[_i] + speed[_i]) < scroll_height) ? all_y0[_i] + speed[_i] : -scroll_height;
			all_y1[_i] = (all_y0[_i] >= 0) ? all_y0[_i] - scroll_height : all_y0[_i] + scroll_height;

			//在0号滑块消失时填入下一个要显示的内容
			if(all_y0[_i] == -scroll_height)
			{
				pointer0[_i] = pointer0[_i] < (strContent.length-2) ? (pointer0[_i] + 2) : (pointer0[_i] + 2) - strContent.length;
			}

			render_drop(_i);
		}
	}

	function render_drop(_i)
	{
		var __di0 = __$('dropimg_'+_i+'0');
		var __di1 = __$('dropimg_'+_i+'1');

		//在页面上渲染
		__di0.innerHTML = getContent(_i, 0);
		__di1.innerHTML = getContent(_i, 1);

		__di0.style.marginTop = all_y0[_i];
		__di1.style.marginTop = all_y1[_i];
	}

	function getContent(cols, rows)
	{
		if (rows==0 )
		{
			return strContent[pointer0[cols]];
		}
		else
		{
			return strContent[pointer1[cols]];
		}
	}

	function stopMove()
	{
		//防止误操作
		if (now_status != 'run')
		{
			return false;
		}
		else
		{
			stop_it(award_pointer);
			if (award_info[0]>-1 && award_info[1]>-1 && award_info[2]>-1)
			{
				clearInterval(domove);
				domove = 0;
				now_status = 'stop';
				__$('start_move').disabled = false;

				display_stop_info();
			}
			else
			{
				award_pointer++;
				setTimeout(stopMove,1000);
			}
		}
	}

	function stop_it(_i)
	{
		award_info[_i] = parseInt(award_num.substr(_i,1));

		var __di0 = __$('dropimg_'+_i+'0');
		var __di1 = __$('dropimg_'+_i+'1');

		//滑块停下
		pointer0[_i] = award_info[_i];
		all_y0[_i] = 0;
		all_y1[_i] = scroll_height;
		render_drop(_i);
		speed[_i] = 0;
	}

	function display_stop_info(){
		if(award_info[0] == award_info[1]  &&  award_info[1] == award_info[2])
		{
			//中奖的提示信息
			__$('stop_info').value = 'You Win!';
		}
		else
		{
			//未中奖的提示信息
			__$('stop_info').value = 'You Lose!';
		}
	}

 	function set_drop_img()
	{
		for(var _i=0; _i<3; _i++)
		{
			var __scroller0 = __$('scroller_'+_i+'0');
			var __scroller1 = __$('scroller_'+_i+'1');

			var __di0 = __$('dropimg_'+_i+'0');
			var __di1 = __$('dropimg_'+_i+'1');

			//初始化容器
			__scroller0.style.left = _start_x + _i * (_div_w + _div_margin_left);
			__scroller1.style.left = __scroller0.style.left;

			__scroller0.style.top = _start_y;
			__scroller1.style.top = _start_y;

			__scroller0.style.width = _div_w;
			__scroller1.style.width = __scroller0.style.width;

			__scroller0.style.height = _div_h;
			__scroller1.style.height = __scroller0.style.height;

			__scroller0.style.paddingTop = _div_padding_top;
			__scroller1.style.paddingTop = __scroller0.style.paddingTop;

			__scroller0.style.display = 'block';
			__scroller1.style.display = 'block';


			//初始化滑块
			__di0.style.width = _drop_w;
			__di1.style.width = _drop_w;

			__di0.style.height = _drop_h;
			__di1.style.height = _drop_h;

			//定义滑块起始位
			all_y0[_i] = 0;
			all_y1[_i] = -scroll_height;

			//定义滑块上显示的内容
			pointer0[_i] = Math.ceil(Math.random() * strContent.length)-1;
			pointer1[_i] = pointer0[_i] < (strContent.length-1) ? (pointer0[_i] + 1) : 0;

			render_drop(_i);

			//设置停盘值
			award_num += Math.round(Math.random() * 9).toString();
		}
		__$('award_str').value = award_num;
	}